This puts the tape into a special 150X normal speed search mode. The
tape can be rewound, also at 150X normal speed, with the MMMMTTTTIIIIOOOOCCCCTTTTOOOOPPPP ioctl
as follows:
struct mtop mt_com;
mt_com.mt_op = MTREW;
mt_com.mt_count = 1;
ioctl(fd, MTIOCTOP, &mt_com);
These commands happen in _i_m_m_e_d_i_a_t_e _m_o_d_e which means the ioctl's return
immediately. While the tape is moving the MMMMTTTTGGGGEEEETTTTAAAAUUUUDDDDIIIIOOOO ioctl can be used
to track the progress of the tape. To determine if the requested
operation has finished use the MMMMTTTTIIIIOOOOCCCCGGGGEEEETTTT ioctl and check the CCCCTTTT____SSSSEEEEEEEEKKKKIIIINNNNGGGG
bit in the error register. The following code, for example, initiates a
search for program 2, then loops until the search is finished continually
requesting the current position:
struct mtget mt_get;
struct mtaudio mt_aud;
bzero(&mt_aud, sizeof(mt_aud));
mt_aud.pno1 = 0;
mt_aud.pno2 = 0;
mt_aud.pno3 = 2;
mt_aud.seektype = MTAUDPOSN_PROG;
ioctl(fd, MTSETAUDIO, &mt_aud);
do {
ioctl(fd, MTGETAUDIO, &mt_aud);
/* do something with the position information */
ioctl(fd, MTIOCGET, &mt_get);
} while (mt_get.mt_erreg & (CT_SEEKING >> 16));
After the second ioctl call, mt_aud contains the program number and the
time codes (if present on the tape) of the location of the tape at the
time of the call.
lllliiiibbbbddddaaaattttaaaauuuuddddiiiioooo
The library contains a group of utility functions for handling some
elements of the sub code data and it contains support for parsing and
understanding the complete content of the digital audio data returned by
a _r_e_a_d(_2).
The utility functions are: DDDDTTTTaaaattttoooottttiiiimmmmeeee,,,, DDDDTTTThhhhmmmmssssffffttttooooffffrrrraaaammmmeeee,,,, DDDDTTTTiiiinnnnccccttttiiiimmmmeeee,,,, DDDDTTTTssssbbbbttttooooaaaa,,,,
DDDDTTTTttttccccvvvvaaaalllliiiidddd,,,, DDDDTTTTttttccccttttooooffffrrrraaaammmmeeee and DDDDTTTTttttiiiimmmmeeeettttooooaaaa.... DDDDTTTTaaaattttoooottttiiiimmmmeeee converts an ASCII string
into a time code suitable for writing on the tape or using as an argument
for the MMMMTTTTSSSSEEEETTTTUUUUDDDDIIIIOOOO ioctl. DDDDTTTTiiiinnnnccccttttiiiimmmmeeee increments such a time code.
DDDDTTTTttttccccttttooooffffrrrraaaammmmeeee converts a time code to a frame number. DDDDTTTTttttccccvvvvaaaalllliiiidddd checks a
time code for validity. DDDDTTTTttttiiiimmmmeeeettttooooaaaa converts a time code to ASCII.
DDDDTTTThhhhmmmmssssffffttttooooffffrrrraaaammmmeeee converts an hours, minutes, seconds, frame quadruple into a
frame number. DDDDTTTTssssbbbbttttooooaaaa converts a string encoded in the six-bit code of
the International Standard Recording Code into an ASCII string.
lllliiiibbbbddddaaaattttaaaauuuuddddiiiioooo supports breaking down of the digital audio data into more
manageable units. You should first read _d_a_t_f_r_a_m_e(_4) for complete details
of the format of a DDDDTTTTFFFFRRRRAAAAMMMMEEEE,,,, the block of data read from the tape. The
DAT parser dissects the frame of data and for each data item it finds, it
can execute a function in your code to which it passes the data. See
DDDDTTTTaaaaddddddddccccaaaallllllllbbbbaaaacccckkkk for complete details of the callback functions. The parser
functions are DDDDTTTTccccrrrreeeeaaaatttteeeeppppaaaarrrrsssseeeerrrr,,,, DDDDTTTTddddeeeelllleeeetttteeeeppppaaaarrrrsssseeeerrrr,,,, DDDDTTTTaaaaddddddddccccaaaallllllllbbbbaaaacccckkkk,,,,
DDDDTTTTppppaaaarrrrsssseeeeffffrrrraaaammmmeeee,,,, DDDDTTTTrrrreeeesssseeeettttppppaaaarrrrsssseeeerrrr,,,, DDDDTTTTrrrreeeemmmmoooovvvveeeeccccaaaallllllllbbbbaaaacccckkkk and DDDDTTTTddddeeeelllleeeetttteeeeppppaaaarrrrsssseeeerrrr....
The following example opens the tape drive, switches it to audio mode
then constantly reads DDDDTTTTFFFFRRRRAAAAMMMMEEEEssss from the tape and hands them to the
parser. It has one callback set up to play the audio data The parser
will call this function with the audio data which it will have byte-
swapped and de-emphasized if the tape's pre-emphasis bit is turned on.
The example uses another callback to keep track of the sampling
frequency.
#include <sys/types.h>
#include <sys/fcntl.h>
#include <sys/mtio.h>
#include <dmedia/audio.h>
#include <dmedia/dataudio.h>
#include <stdio.h>
/*
* playdat.c
*
* simple DAT playing program
* adapted from the dataudio man page example code.
*
*/
#define NUMBLOCKS 4
static int sampsperframe = DTDA_NUMSAMPS44K;
ALport audioport;
int isPaused;
void
playaudio(void *arg, DTDATATYPES type, short *audio)